package com.community.backend.controller;

import com.community.backend.pojo.Notice;
import com.community.backend.pojo.PropertyFee;
import com.community.backend.pojo.dto.NoticeQueryDTO;
import com.community.backend.pojo.dto.PropertyFeeQueryDTO;
import com.community.backend.service.NoticeService;
import com.community.backend.service.PropertyFeeService;
import com.community.backend.utils.PageResult;
import com.community.backend.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
物业费
 */
@Slf4j
@RestController
@RequestMapping("/propertyFee")
public class PropertyFeeController {
    @Autowired
    private PropertyFeeService propertyFeeService;
    @GetMapping("/page")
    public Result<PageResult> page(PropertyFeeQueryDTO propertyFeeQueryDTO) {
        log.info("物业费分页信息：{}", propertyFeeQueryDTO);
        //DOTO:在有效期结束后应该不展示 这个应该是用户界面不展示
        //另外 我们的状态 有已过期，这个怎么弄
        PageResult pageResult = propertyFeeService.pageQuery(propertyFeeQueryDTO);
        return Result.success(pageResult);
    }
    @GetMapping("/{id}")
    public Result propertyFeeDetail(@PathVariable String id) {
        PropertyFee propertyFee = propertyFeeService.propertyFeeDetail(id);
        return Result.success(propertyFee);
    }

    /**
     * 催款
     * @param id
     * @return
     */
    @GetMapping("/publish/{id}")
    public Result PublishPropertyFee(@PathVariable String id) {
        propertyFeeService.selectById(id);
        return Result.success();
    }
    @PostMapping
    public Result save(@RequestBody PropertyFee propertyFee) {
        log.info("添加物业费信息：{}", propertyFee);
        propertyFeeService.save(propertyFee);
        return Result.success("添加成功");
    }
    @PutMapping
    public Result Update(@RequestBody PropertyFee propertyFee) {
        log.info("修改物业费信息：{}", propertyFee);
        propertyFeeService.update(propertyFee);
        return Result.success();
    }
    @DeleteMapping("/{id}")
    public Result DeleteById(@PathVariable String id) {
        log.info("删除物业费信息：{}", id);
        propertyFeeService.deleteById(id);
        return Result.success("删除成功");
    }

}
